package com.learn.demo.model;

import java.io.Serializable;

public class HttpResponseBody<E> implements Serializable {
    private String code;

    private String msg;

    private E data;

    public HttpResponseBody(){
    }

    public HttpResponseBody(String code, String msg, E data){
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public HttpResponseBody(String code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public E getData() {
        return data;
    }

    public void setData(E data) {
        this.data = data;
    }

    public static HttpResponseBody successResponse(String message) {
        return new HttpResponseBody("0000", message);
    }

    public static <T> HttpResponseBody<T> successResponse(String message,T singleData) {
        return new HttpResponseBody<>("0000", message, singleData);
    }

    public static HttpResponseBody failResponse(String message) {
        return new HttpResponseBody("9999", message);
    }
}
